<template>
  <div :class="is_edit?'shelf-card edit':'shelf-card'" @click="handleToRead">
    <div class="box-top">
      <div class="box-left">
        <span class="name">{{name}}</span>
        <span class="writer">{{writer}} 著</span>
        <span v-if="new_chapter" style="font-size:14px;color:rgba(6,27,65,.45);">最新</span>
        <span class="new">{{new_chapter}}</span>
      </div>
      <div class="box-right">
        <el-image :src="image" lazy class="img">
          <div slot="error">
            <img src="http://foglake.sanye666.top/images/default-covor.jpg" alt />
          </div>
        </el-image>
      </div>
    </div>
    <div class="box-bottom">
      <span class="tag">{{is_over}}</span>
      <span class="tag">{{type}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "shelfcard",
  props: {
    name: String,
    writer: String,
    image: String,
    is_over: String,
    type: String,
    new_chapter: String,
    is_edit: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  methods: {
    handleToRead() {
      if (this.is_edit) {
        return;
      }
      this.$emit("handleToRead");
    },
  },
};
</script>

<style lang="scss" scoped>
.shelf-card {
  width: 590px;
  height: 236px;
  background: rgba(255, 255, 255, 1);
  border-radius: 12px;
  padding: 24px 24px 18px 32px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  cursor: pointer;
  &:hover {
    transform: translateY(-3px);
    transition: all 0.3s linear;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  }
  .box-top {
    width: 100%;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(5, 27, 65, 0.05);
    padding-bottom: 26px;
    margin-bottom: 18px;
    .box-left {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      .name {
        font-size: 24px;
        font-family: Microsoft YaHei;
        font-weight: 600;
        color: rgba(6, 27, 64, 0.65);
        line-height: 24px;
        margin-bottom: 8px;
      }
      .writer {
        font-size: 12px;
        font-family: Microsoft YaHei;
        font-weight: 600;
        color: rgba(6, 27, 65, 0.45);
        line-height: 22px;
        margin-bottom: 33px;
      }
      .new {
        font-size: 14px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(6, 27, 65, 0.45);
        line-height: 22px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
    }
    .box-right {
      .img {
        width: 92px;
        height: 124px;
        border-radius: 8px;
      }
    }
  }
  .box-bottom {
    .tag:first-child {
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(189, 141, 255, 1);
      border: 1px solid rgba(189, 141, 255, 1);
      border-radius: 24px;
      padding: 6px 14px;
      margin-right: 8px;
    }
    .tag:last-child {
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(255, 129, 129, 1);
      line-height: 24px;
      border: 1px solid rgba(255, 129, 129, 1);
      border-radius: 24px;
      padding: 6px 14px;
    }
  }
}

.edit:hover {
  transform: translateY(0px);
  box-shadow: 0 0 0 0 rgb(0, 0, 0);
}
</style>